package game.engine.assets 
{
	import org.flixel.*;
	import game.engine.levels.*;
	/**
	 * Any interactive entity
	 * @author kqikz
	 */
	public class MenuDialog extends FlxGroup
	{

		var menuItems = new Array("Inventory","Stats","Quit");
		var selectedItem:Number = 0;
		var bgSprite:FlxSprite;
		/**
		 * Constructor
		 * @param	X	X location of the entity
		 * @param	Y	Y location of the entity
		 */
		public function MenuDialog(X:Number=100, Y:Number=100,Cap:Number=10):void {
			super(Cap);
			bgSprite = new FlxSprite(X,Y);
			bgSprite.makeGraphic(300,100);
			bgSprite.alpha = 0.75;
			bgSprite.scrollFactor.x = 0;
			bgSprite.scrollFactor.y = 0;
			bgSprite.color = 0x0000EE;
			add(bgSprite);
			drawMenu();
		}
		
		override public function update():void{
			super.update();
			var keyPressed:Boolean = false;
			if (FlxG.keys.justPressed("DOWN")){
				keyPressed = true;
				selectedItem++; 
			}
			if (FlxG.keys.justPressed("UP")){
				keyPressed = true;
				selectedItem--; 
			}
			if (selectedItem < 0)
				selectedItem = 0;
			if (selectedItem > 2)
				selectedItem = 2;
			if (keyPressed){
				clear();
				add(bgSprite);
				drawMenu();
			}
		}
		
		private function drawMenu():void{
			var addText:String="   "
			for(var i=0;i<menuItems.length;i++){
				if (selectedItem == i)
					addText = " * ";
				else
					addText = "   ";
				var item:FlxText = new FlxText(0, 0+i*15, 150, addText+menuItems[i]);
				add(item);
			}
			
		}

		
	}
}
